package state

import "time"

type NodeState struct {
	NodeID    string    `json:"node_id"`
	IP        string    `json:"ip"`
	Priority  int       `json:"priority"` // 当前计算出的优先级
	Healthy   bool      `json:"healthy"`
	Timestamp time.Time `json:"timestamp"`
	Seq       uint64    `json:"seq"`       // 递增序列号，防重放
	VIPBound  bool      `json:"vip_bound"` // 是否认为自己持有 VIP
}

type LocalState struct {
	ConfigPriority int
	BasePriority   int
	FailedChecks   int
	WeightPerCheck int
}

func (s *LocalState) CalculatePriority() int {
	return s.BasePriority - (s.FailedChecks * s.WeightPerCheck)
}
